package com.accp.vehiclecare.action.zbaction;

import com.accp.vehiclecare.biz.zbbiz.PostBiz;
import com.accp.vehiclecare.pojo.Station;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@Api(tags="日志接口模块")
@RestController
@RequestMapping("/api/post")
public class PostAction {
    @Autowired
    private PostBiz pbiz;

    @ApiOperation(value="分页查询岗位", notes = "根据当前页数，每页多少行查询出分页数据", httpMethod = "GET")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="path", name = "p", value = "当前页数", example = "1", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="path", name = "s", value = "每页多少行", example = "3", required = true, dataType = "int")
    })
    @GetMapping("{p}/{s}")
    public PageInfo<Station> queryAllStaff(@PathVariable Integer p, @PathVariable Integer s) {
        return pbiz.SelectPost(p,s);
    }
    @ApiOperation(value="分页查询岗位", notes = "根据当前页数，每页多少行查询出分页数据", httpMethod = "POST")
    @GetMapping ("add/{name}")
    public Map<String,Object> addStat(@PathVariable String name){
        Map<String,Object> message=new HashMap<String,Object>();
        boolean count=pbiz.addStation(name);
        if (count){
            message.put("code","200");
            message.put("msg","ok");
        }
        return message;
    }
    @ApiOperation(value="分页查询岗位", notes = "根据当前页数，每页多少行查询出分页数据", httpMethod = "DELETE")
    @DeleteMapping ("remove/{id}")
    public Map<String,Object> removeStat(@PathVariable Integer id){
        Map<String,Object> message=new HashMap<String,Object>();
        boolean count=pbiz.removeStation(id);
        if (count){
            message.put("code","200");
            message.put("msg","ok");
        }
        return message;
    }
}
